home *** CD-ROM | disk | FTP | other *** search
- Path: severus.mbfys.kun.nl!rhialto
- From: rhialto@mbfys.kun.nl (Olaf Seibert)
- Newsgroups: comp.sys.cbm
- Subject: Re: CHRGET routine on the C=64
- Date: 7 Feb 1996 20:56:27 GMT
- Organization: University of Nijmegen, The Netherlands
- Distribution: world
- Message-ID: <4fb3lr$ecs@wn1.sci.kun.nl>
- References: <s10f1bfd.037@shands.ufl.edu>
- NNTP-Posting-Host: severus.mbfys.kun.nl
-
- In <s10f1bfd.037@shands.ufl.edu> mello.med@shands.ufl.edu writes:
-
- |I want to incorporate some of my own routines into BASIC. The
- |C=64 Programmer Reference Guide is not much help. This is all I
- |could find on it:
- |
- |CHRGET routine is used by BASIC to get each character/token.
- |This makes it simple to add new BASIC commands.... A common way
- |to use this method is to specify a character (@ for example)
- |which will occur before any of the new commands. The new CHRGET
- |routine will search for the special character. If none if
- |present, control is passed to the normal BASIC CHRGET routine.
- |If the special character is present, the new command is
- |interpreted and executed by your machine language program. This
- |minimizes the extra execution time added by the need to search
- |for additional commands. This technique is often called a wedge.
- |
- |Now, I understand this means that when you RUN a program, CHRGET
- |will search the BASIC RAM and look for your special symbol in
- |addition to all the regular commands. Is this a correct
- |assumption? My question is: (1) How do I change the vector
- |from the normal CHRGET routine to point to my CHRGET routine to
- |search through RAM for my @ of whatever else it will be. (2)
- |Where in memory do I store my CHRGET routine and the routine
- |after the @ to be executed.
-
- 1: CHRGET is itself in RAM, so you can change it in-place. Here is
- a fragment from the PET memory map (C64 addresses vary slightly):
-
- CHRGET 0070-0087 112-135 Subroutine: Get Next Byte of BASIC Text
- CHRGOT 0076 118 Entry to Get Same Byte of Text Again
- TXTPTR 0077-0078 119-120 Pointer: Current Byte of BASIC Text
- 0070 INC $77 BNE $0076 INC $78
- 0076 LDA $xxxx CMP #$3A BCS $0087
- CMP #$20 BEQ $0070 SEC SBC #$30 SEC SBC #$D0
- 0087 RTS
- C=1 for digits, Z=1 for end of statement/line
-
- 2: There are basically 2 ways to patch CHRGET. One at the start, and
- one somewhere after CHRGOT. You place a JMP to your code at the desired
- location, which first does the work that CHRGET or CHRGOT normally does.
- Then, it checks if your special character has been found and if so, it
- acts on it.
-
- |Any help with this problem would be greatly appreciated :-)
- |
- |If you could please respond by e-mail to mello.med@shands.ufl.edu
- |because I don't have access to a newsreader as of yet.
-
- Done.
-
- |Thanks >Steve M.
- -Olaf.
- --
- ___ Olaf 'Rhialto' Seibert rhialto@mbfys.kun.nl The only excuse
- \X/ for making a useless thing is that one admires it intensely. -O.W.
-